package com.doge.calcalbum.db.model

import androidx.room.Entity
import androidx.room.PrimaryKey
import com.doge.calcalbum.utils.FileUtils
import java.io.File

@Entity(tableName = "album")
data class Album(
    @PrimaryKey(autoGenerate = true)
    val id: Int = 0,
    val coverEntryId: Int?,
    val title: String,
    val createTime: Long,
    val count: Int,
    val type: Int,
    val cover: String? = null
) {
    companion object {
        const val DEFAULT_PICTURE_ID = 1 // 默认相册
        const val DEFAULT_VIDEO_ID = DEFAULT_PICTURE_ID + 1
        const val TYPE_PICTURE = 0
        const val TYPE_VIDEO = 1

        fun albumFileDir(albumId: Int): File {
            return File(
                FileUtils.filesDir("albums"), albumId.toString()
            ).also { if (!it.exists()) it.mkdirs() }
        }
    }
}

